home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
filefunctions
/
example1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
3KB
|
93 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) Amiga C Club (ACC) */
/* -------------------------- ------------------ */
/* */
/* Manual: AmigaDOS Amiga C Club */
/* Chapter: File Functions Tulevagen 22 */
/* File: Example1.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 93-03-15 */
/* Version: 1.0 */
/* */
/* Copyright 1993, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to create a directory called */
/* "MyDirectory" on the RAM disk. */
/* Include the dos library definitions: */
#include <dos/dos.h>
/* Now we include the necessary function prototype files: */
#include <clib/dos_protos.h> /* General dos functions... */
#include <stdio.h> /* Std functions [printf()...] */
#include <stdlib.h> /* Std functions [exit()...] */
/* Set name and version number: */
UBYTE *version = "$VER: AmigaDOS/FileFunctions/Example1 1.0";
/* Declared our own function(s): */
/* Our main function: */
int main( int argc, char *argv[] );
/* Main function: */
int main( int argc, char *argv[] )
{
/* A "BCPL" pointer to our lock: */
BPTR my_dir_lock;
/* Create a directory: */
my_dir_lock = CreateDir( "RAM:MyDirectory" );
/* If we got a lock on the directory we have successfully */
/* created it. However, if we do not have any lock the */
/* directory could not be created. */
if( my_dir_lock == NULL )
{
/* We could not create the directory! */
printf( "Error! Could not create the new directory!\n" );
/* Exit with an error code: */
exit( 20 );
}
/* We have successfully created the directory! We must */
/* now be careful to unlock it as soon as we do not */
/* need the lock any more. */
printf( "The directory was successfully created!\n" );
/* As soon as you do not need the lock on the */
/* directory any more you should unlock it! */
UnLock( my_dir_lock );
/* Inform the user: */
printf( "Directory unlocked!\n" );
/* The End! */
exit( 0 );
}